<h2>{{ title }}</h2>

{% if objects.count %}

{% if options.hasOrder %}
<form action="{{ base }}/order" method="post">
{% endif %}

<table class="table table-striped table-condensed">
	<thead>
		<tr>
			{% for column in columns %}
			<th>{{ column.comment }}</th>
			{% endfor %}
			<th>Действия</th>
		</tr>
	</thead>
	<tbody>
		{% for object in objects %}
		<tr>
			{% for property, column in columns %}
			<td>
				{% if property == options.modelTitleColumn %}<a href="{{ base }}/edit?id={{ object.id }}">{% endif %}
				
				{% if column.type=='image' %}
					{% if object[property] and object[property]!='' %}<img src="{{T4.Root.URL}}/public/{{ object[property] }}.w50.preview" alt="{{ object[options.modelTitleColumn] }}" />{% else %}-{% endif %}
				{% elseif column.type=='text' %}
					{{ object[property]|striptags }}
				{% else %}
					{% if options.hasOrder and property==options.modelOrderColumn and column.type=='int' %}
						<input type="text" name="{{property}}[{{object.id}}]" value="{{ object[property] }}" class="input-mini" />
					{% else %}
						{{ object[property] }}
					{% endif %}
				{% endif %}
				
				{% if property == options.modelTitleColumn %}</a>{% endif %}
			</th>
			{% endfor %}
			<td>
				<a href="{{ base }}/edit?id={{ object.id }}"><i class="icon-edit"></i></a>
				<a href="{{ base }}/delete?id={{ object.id }}"><i class="icon-trash"></i></a>
			</td>			
		</tr>
		{% endfor %}
	</tbody>
</table>

{% if options.hasOrder %}
<div class="form-actions">
	<button type="submit" class="btn btn-primary" />Сохранить порядок</button>
</div>
</form>
{% endif %}

{% else %}
<p>Список пуст</p>
{% endif %}